// JavaScript Document
$(function () {
	initDetail();	
});
//初始化
function initDetail(){
	getInfo(getQueryString("id"));	
}
//获取详情
function getInfo(id){
	var str = 'crporUuid='+encodeURIComponent(id);
	getOData(str,"corePointsOrder/views",{fn:function(oData){
		if(oData.code == 1) {
			$(".crporGoodsName").text(oData.data.crporGoodsName || "");
			$(".crporUserName").text(oData.data.crporUserName || "");
			$(".crporCdate").text(oData.data.crporCdate || "");
			$(".crporUdate").text(oData.data.crporUdate || "");
			var crporStatusCH='交易成功';
			var crporStatus=oData.data.crporStatus;
			if(crporStatus==2){//1支付中2支付成功3支付失败4已发货5交易成功
				crporStatusCH='支付成功';
			}else if(crporStatus==3){
				crporStatusCH='支付失败';
			}else if(crporStatus==4){
				crporStatusCH='已发货';
			}else if(crporStatus==5){
				crporStatusCH='交易成功';
			}
			$(".crporStatus").text(crporStatusCH || "");
			$(".crporName").text(oData.data.crporName || "");
			$(".crporTel").text(oData.data.crporTel || "");
			$(".crporMail").text(oData.data.crporMail || "");
			$(".crporCity").text(oData.data.crporCity || "");
			$(".crporAddress").text(oData.data.crporAddress || "");
			$(".crporNumber").text(oData.data.crporNumber || "");
			$(".crporPrice").text(oData.data.crporPrice || "");
			$(".crporTotal").text(oData.data.crporTotal || "");
			$(".crporSjFee").text(oData.data.crporSjFee || "");
			$(".crporSyScore").text(oData.data.crporSyScore || "");
			$(".crporDkFee").text(oData.data.crporDkFee || "");
			$(".crporRemarks").text(oData.data.crporRemarks || "");
			var imgUrl="/"+oData.data.list[0].cratmDir+"/"+oData.data.list[0].cratmFileName;
			getImageWidthHeight(urlfile+"/coreAttachment/image/get/thumb/"+oData.data.list[0].cratmUuid,function(realWidth,realHeight){
				var width = 0;
				var height = 200;
				//如果真实的宽度大于浏览器的宽度就按照200显示
				if(realHeight>=height){
					width = realWidth/realHeight*height;
					$(".preimg").css("width",width).css("height",height);
				}
				else{//如果小于浏览器的宽度按照原尺寸显示
					$(".preimg").css("width",realWidth+'px').css("height",realHeight+'px');
				}
				$(".preimg").attr("src",urlfile+"/coreAttachment/image/get/thumb/"+oData.data.list[0].cratmUuid);
				$(".preimg").attr("data-filename",imgUrl);
			});
		} else {
			alert(data.errMsg);
		}
	}});
}